package com.example.emergencyattempt01.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextClock;
import android.widget.TextView;
import com.example.emergencyattempt01.R;

import java.util.List;

public class AllTypeDialog_ListViewAdapter extends BaseAdapter {
    Context context;
    List<String> typeList;
    ViewHolder viewHolder;
    class ViewHolder
    {
        TextView nameField;
    }

    public AllTypeDialog_ListViewAdapter(Context context, List<String> typeList) {
        this.context = context;
        this.typeList = typeList;
    }

    @Override
    public int getCount() {
        return typeList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater inflater=LayoutInflater.from(context);
        if(convertView==null)
        {
            convertView=inflater.inflate(R.layout.all_type_dialog_list_item,null);
            viewHolder=new ViewHolder();
            viewHolder.nameField=convertView.findViewById(R.id.type_name);
            convertView.setTag(viewHolder);
        }
        else
        {
            viewHolder=(ViewHolder) convertView.getTag();
        }

        viewHolder.nameField.setText(typeList.get(position));

        return convertView;
    }
}
